﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesAdd.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeReceivablesAdd" %>
<%--新增应收帐款--%>
<div class="pageContent">
	<form method="post" action="FTradeModel/FTradeReceivablesAdd.aspx?ajaxmethod=add&IsHuanJi=<%=IsHuanJi %>&NewFCatheringId=<%=NewFCatheringId %>" class="pageForm required-validate" onsubmit="return validateCallbackFTradeReceivablesAdd(this, navTabAjaxDone);">
		<div class="pageFormContent" layoutH="56">
                <h2 style=" padding:0px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">基本信息</h2>
			        <p>
				<label>合 同 号：</label>
				<input name="HeTongHao" type="text" class="required" value="" />
			</p>
			        <p>
				<label>销售时间：</label>
				<input name="XiaoShouShiJian" class="required date" type="text" value="" alt=""/>
			      </p>
			        <p>
				        <label>经 销 商：</label>
                        <input name="JingXiaoShang" type="text" value="" class="required textInput autocomplete" completetag="agentlists" autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" swidth="300"/>
			        </p>
                    <p>
				        <label>营业经理：</label>
				        <input name="YingYeJingLi" class="required" type="text"  value="" alt="请输入营业经理"/>
			        </p>
                    <p>
				        <label>终端用户：</label>
				        <input name="ZDYongHu" class="" type="text"  value="" alt=""/>
			        </p>

                    <div class="divider"></div>
			        <p>
				        <label>型    号：</label>
                        <%=GetMacType("select", "XingHao", "")%>
			        </p>
                    <p>
				        <label>机    号：</label>
				        <input id="FTradeReceivablesAdd_JiHao" name="JiHao" class="required" type="text" size="" alt=""/>
			            <span class="info" style="color:Red!important;" id="FTradeReceivablesAdd_JiHao_Hit"></span>
                    </p>
                    
                    <div class="divider"></div>
			        <p>
				        <label>单    价：</label>
				        <input id="FTradeReceivablesAdd_Price" name="Price" class="required inputFloat" type="text" value="0" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>
                    <p>
				        <label>GPS费 用：</label>
				        <input id="FTradeReceivablesAdd_GPSFeiYong" name="GPSFeiYong" class="required inputFloat" type="text" value="0" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>
                    <p>
				        <label>月促销折让金额：</label>                        
                        <input id="FTradeReceivablesAdd_YueCuXiaoJinE" name="YueCuXiaoJinE" class="required inputFloat" type="text"  value="0" style="width:114px;" size="" alt=""/>
                        
			        </p>
                     <p>
				        <label>GPS 号：</label>
				        <input name="GPSNum" class="" type="text" value="" size="" alt=""/>
			        </p>
                    <p>
				        <label>利息收入：</label>
				        <input  name="InterestIncome" class="required inputFloat" type="text" value="0" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>
                    <div class="divider"></div>
			        <p>
				        <label>合同金额：</label>
				        <input id="FTradeReceivablesAdd_HeTongJinE" name="HeTongJinE" class="required inputFloat" type="text" value="0" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>
                    <p>
				        <label>返还利息额：</label>
				        <input  name="FanHuanLiXi" class="inputFloat" type="text" value="0" size="" alt=""/>
                        <span class="unit">元</span>
			        </p>
                   <%-- <p>
				        <label>到期日：</label>
				        <input name="DaoQiRi" class="" type="text" value="" alt=""/>
			        </p>--%>
                    
                    <%--<div style="clear:both; border:1px solid #10558C; height:50px; padding:5px;2px; margin-bottom:3px; background-color:">
                        <b>&nbsp;&nbsp;注：出口机器请填:</b><br/>
                         <p>
				            <label>外币金额：</label>
				            <input name="CurrencyAmount" class="inputFloat" type="text" value="0" size="" alt=""/>
                            &nbsp;<input  name="Currency" class="" type="text" size="3" value="USD" size="" alt=""/>
			            </p>
                        <p>
				            <label>外币汇率：</label>
				            <input name="Rate" class="inputFloat" type="text" value="0" size="" alt=""/>
                        </p>
                    </div>--%>
                    <div style="clear:both;"></div>
				    <label>合同付款条款：</label>
				    <textarea name="FuKuanTiaoKuan" cols="80" rows="4" ></textarea>
                    <div style="clear:both;margin-bottom: 5px;"></div>
               
                  <h2 style=" padding:10px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">收款条款:</h2>
                
                    <div style="clear:both;margin-bottom: 5px;"></div>
                    <label>请选择收款条款：</label>
                    <select id="FTradeReceivablesAdd_XiaoShouLeiXing" name="XiaoShouLeiXing" class="required">
					    <%=GetXiaoShouLeiXing("全款")%>
			        </select>
                    <div id="FTradeReceivablesAdd_ShowSummary" style=" line-height:30px; color:Red; font-weight:bold;" >
                       
                    </div>

                    <div style="clear:both;"></div>
                    <div id="FTradeReceivablesAdd_ShowXXLSPage" style=" border:1px dotted #B8D0D6;  margin:5px 0px; ">
                        <%--显示显示销售对应的配置--%>
                    </div>
                    <script type="text/javascript">
                        $(document).ready(function () {

                            $("#FTradeReceivablesAdd_XiaoShouLeiXing").change(function () {
                                changeXiaoShouLeiXing($(this).val());
                            })
                            function changeXiaoShouLeiXing(key) {
                                key = encodeURI(key);
                                //2013-07-13
                                var url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?tag=add&key=" + key
                                $("#FTradeReceivablesAdd_ShowXXLSPage").loadUrl(url);
                                //return false;
                                //
                                //var url = "FTradeModel/GetPageFTradeSaleTypeConfigAdd.aspx?key=" + key
                               // $("#FTradeReceivablesAdd_ShowXXLSPage").loadUrl(url);
                                //
                                url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?ajaxmethod=getconfigsummary&key=" + key
                                $("#FTradeReceivablesAdd_ShowSummary").loadUrl(url);

                            }
                            changeXiaoShouLeiXing("全款");
                        })
                </script>
             
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li id="FTradeReceivablesAdd_BtnSave" ><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>

<script>
    $(document).ready(function () {
        $("#FTradeReceivablesAdd_JiHao").blur(function () {
            var $data = {};
            var $this = $(this);
            $data["JiHao"] = $this.val();
            var url = "/MachineSys/sysAjaxDone.ashx?ajaxmethod=ftradereceivablescheckjihao&FTradeID=0"
            $.ajax({
                type: 'post',
                url: url,
                data: $data,
                async: false,
                cache: false,
                success: function (json) {
                    $("#FTradeReceivablesAdd_JiHao_Hit").html(json);
                    if (json != "") {
                        $("#FTradeReceivablesAdd_BtnSave").hide();
                    }
                    else {
                        $("#FTradeReceivablesAdd_BtnSave").show();
                    }
                }
            });
        });
        //处理合同金额
        $("#FTradeReceivablesAdd_Price,#FTradeReceivablesAdd_GPSFeiYong,#FTradeReceivablesAdd_YueCuXiaoJinE").change(function () {
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesAdd_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesAdd_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesAdd_YueCuXiaoJinE").val());

            $("#FTradeReceivablesAdd_HeTongJinE").val(Price + GPSFeiYong + YueCuXiaoJinE);

        })

    });

    //新增时需要处理 金额是否与合同金额一致
    function validateCallbackFTradeReceivablesAdd(form, callback) {
        var $form = $(form);
        var $XiaoShouLeiXing = $("#FTradeReceivablesAdd_XiaoShouLeiXing").val();
        var $HeTongJinE = $("#FTradeReceivablesAdd_HeTongJinE").val();
        var $inputPageJinE = 0;
        $("#FTradeReceivablesAdd_ShowXXLSPage").find(":text[name='Page_JinE']").each(function () {
            $inputPageJinE = $inputPageJinE + parseFloat($(this).val());
        });
        if (parseFloat($HeTongJinE).toFixed(4) != parseFloat($inputPageJinE).toFixed(4)) {
            alertMsg.warn("合同金额与销售类型[" + $XiaoShouLeiXing + "]相应金额不一致,请检查更改后再提交.");
            return false;
        }

        $("#FTradeReceivablesAdd_BtnSave").find("button").attr("disabled", "disabled").html("添加中......");
        setTimeout(function () { $("#FTradeReceivablesAdd_BtnSave").find("button").removeAttr("disabled").html(" 添 加 "); }, 20000);

        return validateCallback(form, callback);
    }
</script>
